#!/bin/bash

# cp the script file into server, and execute it

user=$1
server=$2
scriptfile=$3
remotefilename=`date '+%ss'.sh`
scp -i ssh_key ${scriptfile} ${user}@${server}:~/${remotefilename}
ssh -i ssh_key ${user}@${server} "chmod +x ~/${remotefilename};~/${remotefilename}"
#cat ${scriptfile} |xargs ssh -i ssh_key ${user}@${server}